import uuid

from fastapi import UploadFile, File, APIRouter

from common.GlobalConfig import config
from modules.http_resp import ResponseSuccess

router = APIRouter()

@router.get("/uploadFile")
async def uploadFile(file: UploadFile = File(...)):
    # 读取文件内容（如果需要）
    contents = await file.read()
    fileName = uuid.uuid4()

    # 这里可以进行保存文件、处理文件等操作
    with open(f"{config.SAVE_FILE_PATH}/{fileName}.{file.content_type}", "wb") as f:
        f.write(contents)
    return ResponseSuccess({"filename": f"{config.SAVE_FILE_PATH}/{fileName}.{file.content_type}"})